﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BHair.Business;
using BHair.Base;
using BHair.Report;
using BHair.SystemSet;
using System.Data.SqlClient;
using System.Configuration;
using BHair.xitong;

namespace BHair
{
    public partial class frmzhu : Form
    {
        public frmzhu()
        {
            InitializeComponent();
        }

        string constr = ConfigurationManager.ConnectionStrings["BHair.Properties.Settings.BHairDBConnectionString"].ConnectionString;
        private void frmzhu_Load(object sender, EventArgs e)
        {
            //打开提醒
           
            //tabPage1.Parent = null;
            //tabPage2.Parent=null;
            tabControl1.SizeMode = TabSizeMode.Fixed;
            tabControl1.ItemSize = new Size(0,1);
            /*frmgj fj = new frmgj();
            fj.Show(this.dockPanel1,WeifenLuo.WinFormsUI.Docking.DockState.DockLeft);
            fj.Text = "窗体导航";
             * */
            
           
        }

        private void 退出软件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void 会员消费ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format( "SELECT [xiaofei] FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr =comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["xiaofei"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                frmPays_List xf = new frmPays_List();
                xf.Show(this.dockPanel1);
                xf.Text = "消费管理";
            }
        }

        public void 商品资料ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = string.Format("SELECT [spsz] FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'", chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql, conn);
            SqlDataReader sdr = comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read())
            {
                qx = Int32.Parse(sdr["spsz"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                frmItems_List sp = new frmItems_List();
                sp.Show(this.dockPanel1);
                sp.Text = "商品资料";
            }
        }
        //商品资料
        public void sp() 
        {
            pictureBox1.Hide();
            skinLabel8.Hide();
            frmItems_List sp = new frmItems_List();
            sp.Show(this.dockPanel1);
            sp.Text = "商品资料";
        }
        //员工资料
        public void yg() 
        {
            frmEmployee_List fy = new frmEmployee_List();
            fy.Show(this.dockPanel1);
            fy.Text = "员工资料";
        }
        //会员分类
        public void fl() 
        {
            frmMember_List hyfl = new frmMember_List();
            hyfl.Show(this.dockPanel1);
            hyfl.Text = "会员分类";
        }
        //会员卡
        public void vip() 
        {
            frmMember vip1 = new frmMember();
            vip1.Show(this.dockPanel1);
            vip1.Text = "会员信息";
        }
        //消费
        public void xf() 
        {
            frmPays_List fx = new frmPays_List();
            fx.Show(this.dockPanel1);
            fx.Text = "消费管理";
        }
        //表表统计
        public void bb() 
        {
            frmReport_Month sz = new frmReport_Month();
            sz.Show(this.dockPanel1);
            sz.Text = "每月收支汇总";
        }
        //数据备份
        public void bak() 
        {
            frmbak bak = new frmbak();
            bak.ShowDialog();
        }

        private void 员工奖罚记录ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //frmEmployee_Money ygjf = new frmEmployee_Money();
            //ygjf.Show(this.dockPanel1);
           /* frmgj fj = new frmgj();
            fj.Show(this.dockPanel1, WeifenLuo.WinFormsUI.Docking.DockState.DockLeft);
            fj.Text = "窗体导航";
            * */
            tabControl1.SelectedTab = tabPage1;
            pictureBox1.Show();
            skinLabel8.Show();
            /*tabControl1.SizeMode = TabSizeMode.Fixed;
            tabControl1.ItemSize = new Size(55, 15);
             * */
        }

        private void 员工资料ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = string.Format("SELECT[ygsz]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'", chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql, conn);
            SqlDataReader sdr = comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read())
            {
                qx = Int32.Parse(sdr["ygsz"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                frmEmployee_List fy = new frmEmployee_List();
                fy.Show(this.dockPanel1);
                fy.Text = "员工资料";
            }
            conn.Close();
        }

        private void 会员充值统计ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string sql =string.Format( "SELECT[hycztj]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr = comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["hycztj"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                frmDeposit hycz = new frmDeposit();
                hycz.Show(this.dockPanel1);
                hycz.Text = "会员充值统计";
            }
            conn.Close();
        }

        private void 员工工资统计ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string sql =string.Format( "SELECT[yggztj]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr = comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["yggztj"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                frmSalary gz = new frmSalary();
                gz.Show(this.dockPanel1);
                gz.Text = "员工工资统计";
            }
            conn.Close();
        }

        private void 每月收支汇总ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string sql = string.Format("SELECT[myszhz]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'", chuanzhi.userID);
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr = comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["myszhz"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                frmReport_Month sz = new frmReport_Month();
                sz.Show(this.dockPanel1);
                sz.Text = "每月收支汇总";
            }
        }

        private void 账目清单ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

        private void 商品入库ToolStripMenuItem_Click(object sender, EventArgs e)
        {

            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = string.Format("SELECT [sprk] FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'", chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql, conn);
            int qx = 0;
            SqlDataReader sdr = comm.ExecuteReader();
            while (sdr.Read())
            {
                qx = Int32.Parse(sdr["sprk"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                //Formrk rk = new Formrk();
                frmjinhuo rk = new frmjinhuo();
                rk.Show(this.dockPanel1);
                rk.Text = "商品入库";
            }
        }

        private void 会员充值ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format( "SELECT [huiyuanguanli] FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            int qx = 0;
            SqlDataReader sdr = comm.ExecuteReader();
            while(sdr.Read())
            {
                qx =Int32.Parse( sdr["huiyuanguanli"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                frmMember_List hygl = new frmMember_List();
                hygl.Show(this.dockPanel1);
                hygl.Text = "会员管理";
            }
        }

        private void 会员分类ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = string.Format("SELECT [hylx] FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'", chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            int qx = 0;
            SqlDataReader sdr = comm.ExecuteReader();
            while(sdr.Read())
            {
                qx = Int32.Parse(sdr["hylx"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                frmCard fc = new frmCard();
                fc.Show(this.dockPanel1);
                //frmMember_List hyfl = new frmMember_List();
                //hyfl.Show(this.dockPanel1);
                fc.Text = "会员分类";
            }
        }

        private void 收支科目管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = string.Format("SELECT [szkmgl] FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'", chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            int qx = 0;
            SqlDataReader sdr = comm.ExecuteReader();
            while(sdr.Read())
            {
                qx = Int32.Parse(sdr["szkmgl"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                frmSubject_List sjkmgl = new frmSubject_List();
                sjkmgl.Show(this.dockPanel1);
                sjkmgl.Text = "收支科目管理";
            }
        }

        private void 用户设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = string.Format("SELECT [yhsz] FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr = comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["yhsz"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                Frmuser user = new Frmuser();
                user.Show(this.dockPanel1);
                user.Text = "用户设置";
            }
        }

        private void 系统设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format( "SELECT [xtsz] FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr = comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["xtsz"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                pictureBox1.Hide();
                skinLabel8.Hide();
                frmConfig objfrmConfig = new frmConfig();
                objfrmConfig.ShowDialog();
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format( "SELECT [spsz] FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr =comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["spsz"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                tabControl1.SelectedTab = tabPage2;
                pictureBox1.Hide();
                skinLabel8.Hide();
                // TabControl1.SelectedTab = TabPage2
                sp();
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format( "SELECT [huiyuanguanli] FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            int qx = 0;
            SqlDataReader sdr = comm.ExecuteReader();
            while(sdr.Read())
            {
                qx =Int32.Parse( sdr["huiyuanguanli"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                tabControl1.SelectedTab = tabPage2;
                pictureBox1.Hide();
                skinLabel8.Hide();
                fl();
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedTab = tabPage2;
        }

        private void button6_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            string sql =string.Format( "SELECT[jcxf]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            conn.Open();
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr = comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["jcxf"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                tabControl1.SelectedTab = tabPage2;
                pictureBox1.Hide();
                skinLabel8.Hide();
                //bak();
                Frmjcxf jc = new Frmjcxf();
                jc.Show();
            }
        }

        private void 联系我们ToolStripMenuItem_Click(object sender, EventArgs e)
        {

        }

        private void 关于软件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            pictureBox1.Hide();
            skinLabel8.Hide();
            Frmgy gy = new Frmgy();
            gy.ShowDialog();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format( "SELECT[ygsz]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr = comm.ExecuteReader();
            int qx=0;
            while (sdr.Read()) 
            {
                qx=Int32.Parse(sdr["ygsz"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                tabControl1.SelectedTab = tabPage2;
                pictureBox1.Hide();
                skinLabel8.Hide();
                yg();
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedTab = tabPage2;
            pictureBox1.Hide();
            skinLabel8.Hide();
            vip();
        }

       

        private void button7_Click(object sender, EventArgs e)
        {
            SqlConnection conn1 = new SqlConnection(constr);
            conn1.Open();
            string sql =string.Format( "SELECT[xiaofei]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlCommand comm1 = new SqlCommand(sql,conn1);
            SqlDataReader sdr=comm1.ExecuteReader();
            int qx=0;
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["xiaofei"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                tabControl1.SelectedTab = tabPage2;
                pictureBox1.Hide();
                skinLabel8.Hide();
                xf();
            }
        }

        private void button8_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedTab = tabPage2;
            pictureBox1.Hide();
            skinLabel8.Hide();
            bb();
            
        }

        private void 数据备份ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmbak bak = new frmbak();
            pictureBox1.Hide();
            skinLabel8.Hide();
            bak.ShowDialog();
        }

        private void 数据恢复ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmhf hf = new frmhf();
            pictureBox1.Hide();
            skinLabel8.Hide();
            hf.Show();
        }

        private void 数据升级ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql =string.Format( "SELECT[sjsj]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'",chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            SqlDataReader sdr = comm.ExecuteReader();
            int qx = 0;
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["sjsj"].ToString().Trim());
            }
            if (qx == 0) 
            {
                MessageBox.Show("无此权限");
            }else
            {
            //frmshengji shengji = new frmshengji();
            //shengji.ShowDialog();

            }
            conn.Close();
        }

        private void 计次消费明细ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = string.Format("SELECT[jcxfmx]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'", chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            int qx = 0;
            SqlDataReader sdr = comm.ExecuteReader();
            while (sdr.Read()) 
            {
                qx =Int32.Parse( sdr["jcxfmx"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {

                pictureBox1.Hide();
                skinLabel8.Hide();
                frmxmmx xm = new frmxmmx();

                xm.Show(this.dockPanel1);
                xm.Text = "计次消费明细";

            }
            conn.Close();
        }

        private void 更换操作员ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /*frmLogin lg = new frmLogin();
            lg.ShowDialog();
             * */
            frmghyh gh = new frmghyh();
            gh.ShowDialog();
        }

        private void 收支账目清单ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = string.Format("SELECT[zmqd]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'", chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            int qx = 0;
            SqlDataReader sdr = comm.ExecuteReader();
            while (sdr.Read()) 
            {
                qx = Int32.Parse(sdr["zmqd"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {

                pictureBox1.Hide();
                skinLabel8.Hide();
                frmWasteBook_List zmqd = new frmWasteBook_List();
                zmqd.Show(this.dockPanel1);
                zmqd.Text = "账目清单";
            }
        }

        private void 计次消费明细表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            pictureBox1.Hide();
            skinLabel8.Hide();
            frmjcxfmx jc = new frmjcxfmx();
            jc.Show(this.dockPanel1);
            jc.Text = "计次项目消费明细表";
        }

        private void 直接扣款ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection(constr);
            conn.Open();
            string sql = string.Format("SELECT[zjkk]FROM [BHairDB].[dbo].[LoginUser] where LoginUserID='{0}'", chuanzhi.userID);
            SqlCommand comm = new SqlCommand(sql,conn);
            int qx = 0;
            SqlDataReader sdr = comm.ExecuteReader();
            while (sdr.Read()) 
            {
                qx = Int32.Parse(sdr["zjkk"].ToString().Trim());
            }
            if (qx == 0)
            {
                MessageBox.Show("无此权限");
            }
            else
            {
                frmzjkf zj = new frmzjkf();
                zj.ShowDialog();
            }
        }

        private void 销售明细表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmxsmx xsmx = new frmxsmx();
            xsmx.Show(this.dockPanel1);
            xsmx.Text = "销售明细表";
        }

        private void 进货明细报表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmjhmx jin = new frmjhmx();
            jin.Show(this.dockPanel1);
            jin.Text = "进货明细表";
        }

       
    }
}
